package com.mxpio.erp.common.quality.entity;

import com.mxpio.erp.common.inventory.entity.Warehouse;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.security.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "V_MB_ERP_PURCHASE_RECEIPT")
@Schema(description="采购到货报表（基于采购质检单明细统计）")
public class VPurchaseReceipt implements DictAble, Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "ID", updatable = false)
	@Schema(description = "主键")
	private String id;

	@Column(name = "WH_CODE_")
	@Schema(description = "仓库代码")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String whCode;

	@Column(name = "ITEM_CODE_")
	@Schema(description = "物料代码")
	private String itemCode;

	@Column(name = "ITEM_NAME_")
	@Schema(description = "物料名称")
	private String itemName ;

	@Column(name = "UNIT_CODE_")
	@Schema(description = "单位编号")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
	private String unitCode;

	@Column(name = "DRAWING_NO_")
	@Schema(description = "图号")
	private String drawingNo;

	@Column(name = "ITEM_SPEC_")
	@Schema(description = "物料规格")
	private String itemSpec;

	@Schema(description = "供应商编号")
	@Column(name = "PN_CODE_")
	private String pnCode;

	@Schema(description = "供应商名称")
	@Column(name = "PN_NAME_")
	private String pnName;

	@Column(name = "BIZ_NO_")
	@Schema(description = "采购单号")
	private String bizNo;

	@Column(name = "ORIGIN_BIZ_LINE_NO_")
	@Schema(description = "采购单行号")
	private String originBizLineNo;

	@Column(name = "ARRIVAL_QUANTITY_")
	@Schema(description = "到货数量")
	private BigDecimal arrivalQuantity;

	@Column(name = "INSPECTION_BILL_NO_")
	@Schema(description = "质检单号")
	private String inspectionBillNo;

	@Column(name = "CONFIRM_QUANTITY_")
	@Schema(description = "报检数量")
	private BigDecimal confirmQuantity;

	@Column(name = "CHECK_QUANTITY_")
	@Schema(description = "检验数量")
	private BigDecimal checkQuantity;

	@Column(name = "TEST_RESULT_")
	@Schema(description = "检验结论")
	@Dict(dicCode = "MB_QUALITY_CHECK_RESULT")//0不合格，1合格
	private String testResult;

	@Column(name = "RECEIVE_QUANTITY_")
	@Schema(description = "验收合格数量")
	private BigDecimal receiveQuantity;

	@Column(name = "UNQUALIFIED_QUANTITY_")
	@Schema(description = "不合格数量")
	private BigDecimal unqualifiedQuantity;

	@Column(name = "CONCESSION_QUANTITY_")
	@Schema(description = "让步接收")
	private BigDecimal concessionQuantity;

	@Column(name = "UD_BIZ_NO_")
	@Schema(description = "不合格品处理单号")
	private String udBizNo;

	@Column(name = "BPMN_STATUS_")
	@Schema(description = "不合格品处理单处理状态")
	@Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
	private String bpmnStatus;


	@Transient
	private Map<String, String> textMap;

	public String putText(String key, String value) {
		if (textMap == null) {
			textMap = new HashMap<>();
		}
		return textMap.put(key, value);
	}
}
